package com.zxc.domain;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;


public class TableInfo implements Serializable{

	private static final long serialVersionUID = 1L;

	private String tableOwner;
	
	private String tableName;
	
	private List<TableHeader> tableHeaders;
	
	private String[] tableType;
	
	private String[] tableComments;
	

	public TableInfo() {
		super();
	}

	public TableInfo(String tableOwner, String tableName) {
		super();
		this.tableOwner = tableOwner;
		this.tableName = tableName;
	}

	public List<TableHeader> getTableHeaders() {
		return Collections.unmodifiableList(tableHeaders);
	}

	public void setTableHeaders(List<TableHeader> tableHeaders) {
		this.tableHeaders = tableHeaders;
	}

	public String[] getTableType() {
		return tableType;
	}

	public void setTableType(String[] tableType) {
		this.tableType = tableType;
	}

	public String[] getTableComments() {
		return tableComments;
	}

	public void setTableComments(String[] tableComments) {
		this.tableComments = tableComments;
	}

	public String getTableName() {
		return tableName.toUpperCase();
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	public String getTableOwner() {
		return tableOwner.toUpperCase();
	}

	public void setTableOwner(String tableOwner) {
		this.tableOwner = tableOwner;
	}
	
	public String getTableSpecName(){
		return tableOwner == null ? tableName : (tableOwner+"."+tableName);
	}

	public void addTableHeader(TableHeader header){
		if(this.tableHeaders == null){
			setTableHeaders(new ArrayList<TableHeader>());
		}
		this.tableHeaders.add(header);
	}
	
	public void removeTableHeader(TableHeader header){
		this.tableHeaders.remove(header);
	}
}
